const app = getApp()
const attachBaseUrl = app.globalData.attachBaseUrl
Page({
  data: {
    imageList: [],
    imgs: ''
  },
  onLoad(option) {
    this.getContractList(option.id)
  },
  getContractList(id) {
    app.axios('contract', {
      op: 'ajaxContractDetail',
      id: id
    }).then(res => {
      if (res.code && res.item && res.item.imgs && res.item.imgs.length > 0) {
        const imgList = []
        const imgs = []
        res.item.imgs.split(',').forEach((item, index) => {
          const img = {
            id: index,
            url: attachBaseUrl + item,
            isImage: true,
          }
          imgList.push(img)
          imgs.push(attachBaseUrl + item)
        })
        this.setData({
          imageList: imgList,
          imgs: imgs
        })
      }
    })
  },
  preview(e) {
    wx.previewImage({
      current: e.currentTarget.dataset.url,
      urls: this.data.imgs
    })
  }
}); 